package cn.tedu._09deepseek.controller;

import io.github.pigmesh.ai.deepseek.core.DeepSeekClient;
import io.github.pigmesh.ai.deepseek.core.chat.ChatCompletionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {
    //自动装配,注入DeepSeek的实例,调用DeepSeek的接口
    @Autowired
    private DeepSeekClient deepSeekClient;

    /**
     * Flux<ChatCompletionResponse>:流式响应,包含连续的AI响应片段;
     * @param prompt 提示词[问题]
     * @return AI的响应[连续的AI响应片段]
     *
     * 第1种测试思路,通过浏览器输入地址: http://localhost:8080/chat?prompt=你是谁
     * 第2种测试思路,通过网页测试[完成一个网页];
     */
    @GetMapping("/chat")
    public Flux<ChatCompletionResponse> chat(String prompt){
        return deepSeekClient.chatFluxCompletion(prompt);
    }
}
